package com.hong.controller;


import com.hong.bean.User;
import com.hong.dto.CreateUserDTO;
import com.hong.dto.QueryUserDTO;
import com.hong.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@Api(value = "用户", tags = {"用户"})
@RestController
@RequestMapping("user")
public class UserController {


    @Autowired
    private UserService userService;

    @ApiOperation("获取用户列表")
    @GetMapping("list")
    public List<User> getList(QueryUserDTO param) {

        log.info("查询用户信息：{}", "list");

        return userService.getList(param);
    }

    @ApiOperation("保存用户")
    @PostMapping("create")
    public Boolean save(@RequestBody CreateUserDTO param) {
        log.info("查询用户信息：{}", param);
        return true;
    }

    @ApiOperation(value = "登录接口", notes = "登录接口的说明")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "username", value = "用户名", required = true, paramType = "query"),
            @ApiImplicitParam(name = "password", value = "密码", required = true, paramType = "query")
    })
    @PostMapping(value = "/login")
    public Boolean login(@RequestParam("username") String username, @RequestParam("password") String password) {
        return Boolean.TRUE;
    }


}
